package com.bruce.demo2.patterns.demo3.behavioral.demo15.command;

import java.util.ArrayList;
import java.util.List;

/**
 * @PROJECT_NAME: design_patterns
 * @DESCRIPTION: 服务员类 请求者角色
 * @AUTHOR: CNBruceLee
 * @DATE: 2021/8/31 21:05
 */
public class Waitor {

    //持有多个命令对象
    private List<Command> commands = new ArrayList<Command>();

    public void setCommand(Command cmd) {
        //将cmd存储到List集合中
        commands.add(cmd);
    }

    //发起命令的方法
    public void orderUp() {
        System.out.println("美女服务员：大厨，新订单来了。。。。");
        //遍历list集合
        for (Command command : commands) {
            if (command != null) {
                command.execute();
            }
        }
    }
}
